Skip to content

Выравнивание чисел в колонках по разрядности дробной части мин. значения#7

Merged
Stivo182 merged 1 commit intomainfrom
feat/precision-in-column
May 6, 2025
Merged

Выравнивание чисел в колонках по разрядности дробной части мин. значения#7
Stivo182 merged 1 commit intomainfrom
feat/precision-in-column

Conversation

@Stivo182
Copy link
Owner

@Stivo182 Stivo182 commented May 6, 2025

Summary by CodeRabbit

  • New Features
    • Improved formatting of numeric columns in benchmark reports with dynamic decimal precision based on value and measurement unit.
  • Bug Fixes
    • Enhanced handling and display of numeric values, especially for time units, ensuring correct decimal places and formatting.
  • Tests
    • Expanded and updated tests to verify correct formatting of numeric values, including new cases for time representation with decimals.
  • Refactor
    • Standardized marking of columns as numeric across all relevant report columns for consistent processing and display.

@coderabbitai
Copy link

coderabbitai bot commented May 6, 2025

Walkthrough

This change introduces an explicit numeric flag (ЭтоЧисло = Истина) to all relevant benchmark report columns, updates formatting logic to dynamically determine decimal precision based on values and units, and refines how numeric values are represented in reports. It also adjusts associated test cases and adds new tests for number formatting.

Changes

File(s) Change Summary
src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарков...*.os Added ЭтоЧисло = Истина assignment in the Создать() function for all numeric benchmark report columns, explicitly marking them as numeric. No changes to function signatures or other logic.
src/BenchmarkOneScript/core/Классы/ПостроительОтчетаБенчмарков.os Added procedure ОпределитьФорматныеСтроки() to set format strings for numeric columns based on minimum values and units, integrated into the data fill workflow. Adjusted numeric column detection and order of operations after data fill.
src/BenchmarkOneScript/core/Модули/МатематическиеФункцииБенчмарков.os Changed signature of ТолькоЧисла by removing the optional parameter for including undefined values; now strictly checks for numeric types only.
src/BenchmarkOneScript/core/Модули/ПредставленияПоказателейБенчмарков.os Updated Представление and ПредставлениеЧисла to accept and use measurement units for formatting. Added dynamic decimal precision logic via new helper functions ПодобратьРазрядностьДробнойЧасти and РазрядностьЧисла.
tests/ТестыПредставленияПоказателей.os Updated expected outputs in nanosecond formatting tests to include decimal points. Added new exported test procedure Тест_ПредставлениеЧислаСекунды to verify formatting of floating-point seconds with proper decimal precision and sign handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ПостроительОтчетаБенчмарков
    participant Колонка
    participant МатематическиеФункцииБенчмарков
    participant ПредставленияПоказателейБенчмарков

    User->>ПостроительОтчетаБенчмарков: ЗаполнитьДанные()
    ПостроительОтчетаБенчмарков->>Колонка: Проверить ЭтоЧисло
    ПостроительОтчетаБенчмарков->>МатематическиеФункцииБенчмарков: ТолькоЧисла(Значения)
    ПостроительОтчетаБенчмарков->>ПостроительОтчетаБенчмарков: ОпределитьФорматныеСтроки()
    ПостроительОтчетаБенчмарков->>Колонка: Установить форматную строку
    ПостроительОтчетаБенчмарков->>ПредставленияПоказателейБенчмарков: ПредставлениеЧисла(Значение, ЕдиницаИзмерения)
    ПредставленияПоказателейБенчмарков->>ПредставленияПоказателейБенчмарков: ПодобратьРазрядностьДробнойЧасти()
    ПредставленияПоказателейБенчмарков->>ПредставленияПоказателейБенчмарков: РазрядностьЧисла()
    ПредставленияПоказателейБенчмарков-->>ПостроительОтчетаБенчмарков: Отформатированное значение
Loading

Possibly related PRs

Poem

🐇
A hop, a skip, a decimal point,
Now numbers in columns all neatly anoint.
With format strings chosen, precision just right,
Benchmarks are clearer, a data delight!
From nanoseconds swift to seconds anew,
This bunny applauds the improvements from you!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0d4452 and 991cd20.

📒 Files selected for processing (16)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковВерхнийКвартиль.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковВыделяемаяПамять.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковКоэффициентПроизводительности.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковМакс.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковМедиана.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковМин.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковНижнийКвартиль.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковОперацийВСекунду.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковПроцентиль.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковСреднее.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковСтандартнаяОшибка.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковСтандартноеОтклонение.os (1 hunks)
  • src/BenchmarkOneScript/core/Классы/ПостроительОтчетаБенчмарков.os (3 hunks)
  • src/BenchmarkOneScript/core/Модули/МатематическиеФункцииБенчмарков.os (1 hunks)
  • src/BenchmarkOneScript/core/Модули/ПредставленияПоказателейБенчмарков.os (3 hunks)
  • tests/ТестыПредставленияПоказателей.os (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: sonar / test
  • GitHub Check: build (windows-latest, dev)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (macos-latest, dev)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (ubuntu-latest, dev)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (windows-latest, dev)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (macos-latest, dev)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: sonar / test
🔇 Additional comments (23)
src/BenchmarkOneScript/core/Модули/МатематическиеФункцииБенчмарков.os (1)

107-107: Simplified function signature for stricter type checking

The function signature has been simplified by removing the optional parameter ВключаяНеопределено. This change makes the function more strict in its validation as it will now always return Ложь when encountering non-numeric values, rather than optionally skipping Неопределено values.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковСреднее.os (1)

13-13: Appropriate numeric column marking

Adding the ЭтоЧисло = Истина property explicitly identifies this column as containing numeric data, which supports the new formatting logic for aligning numbers in columns by decimal places.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковСтандартнаяОшибка.os (1)

13-13: Appropriate numeric column marking

Adding the ЭтоЧисло = Истина property explicitly identifies this column as containing numeric data, which supports the new formatting logic for aligning numbers in columns by decimal places.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковСтандартноеОтклонение.os (1)

13-13: Appropriate numeric column marking

Adding the ЭтоЧисло = Истина property explicitly identifies this column as containing numeric data, which supports the new formatting logic for aligning numbers in columns by decimal places.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковМедиана.os (1)

13-13: Addition of numeric type flag is appropriate

The ЭтоЧисло = Истина property explicitly marks this column as containing numeric data, which is consistent with the PR objective of aligning numbers in columns based on decimal precision. This flag will allow the report builder to apply appropriate formatting to numeric values.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковМакс.os (1)

13-13: Addition of numeric type flag is appropriate

The ЭтоЧисло = Истина property correctly identifies this Max column as containing numeric data, which supports the implementation of decimal-aligned formatting in reports.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковНижнийКвартиль.os (1)

13-13: Addition of numeric type flag is appropriate

Adding the ЭтоЧисло = Истина property to the Q1 (lower quartile) column correctly identifies it as containing numeric data, which enables consistent decimal formatting across benchmark reports.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковМин.os (1)

13-13: Addition of numeric type flag is appropriate

The ЭтоЧисло = Истина property correctly marks the Min column as numeric, which is essential for the implementation of consistent decimal alignment in benchmark reports. This change aligns with the PR objective of formatting numbers based on the decimal precision of minimum values.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковКоэффициентПроизводительности.os (1)

14-14: Approved: Proper numeric column marking.

Adding the numeric flag (ЭтоЧисло = Истина) to this performance ratio column is correct and consistent with the PR's purpose of improving numeric value alignment in reports.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковПроцентиль.os (1)

17-17: Approved: Proper numeric column marking.

Adding the numeric flag (ЭтоЧисло = Истина) to this percentile column is correct and consistent with the PR's purpose of improving numeric value alignment in reports.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковВыделяемаяПамять.os (1)

13-13: Approved: Proper numeric column marking.

Adding the numeric flag (ЭтоЧисло = Истина) to this memory allocation column is correct and consistent with the PR's purpose of improving numeric value alignment in reports.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковОперацийВСекунду.os (1)

13-13: Approved: Proper numeric column marking.

Adding the numeric flag (ЭтоЧисло = Истина) to this operations-per-second column is correct and consistent with the PR's purpose of improving numeric value alignment in reports.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковВерхнийКвартиль.os (1)

13-13: Correctly added numeric column indicator.

Adding the explicit ЭтоЧисло = Истина flag marks this column as containing numeric data, which enables proper decimal alignment in the report generation process.

src/BenchmarkOneScript/core/Классы/ПостроительОтчетаБенчмарков.os (4)

199-201: Good optimization for numeric column detection.

This check prevents redundant processing by skipping columns that are already explicitly marked as numeric.


204-204: Modified function call to updated signature.

The call to МатематическиеФункцииБенчмарков.ТолькоЧисла() was correctly updated to match its new signature without the second boolean parameter.


187-191: Correct workflow sequencing with comment.

The added comment about order importance and the insertion of the new formatting procedure in the correct sequence is appropriate. It ensures format strings are determined after identifying numeric columns and units, but before determining column sizes.


240-276: Well-implemented procedure for dynamic formatting.

The new ОпределитьФорматныеСтроки() procedure follows a logical approach:

  1. It processes only numeric columns
  2. It determines the minimum value for each column
  3. It properly handles unit conversion when needed
  4. It calculates appropriate decimal precision based on the value and unit
  5. It sets the format string for consistent display

This implementation aligns numeric values in columns by the same decimal precision based on the minimum value, improving readability of benchmark reports.

tests/ТестыПредставленияПоказателей.os (2)

44-55: Updated test expectations with decimal precision.

The test expectations were correctly updated to include decimal points (e.g., changing "10 ns" to "10.0 ns"), reflecting the new formatting precision rules.


73-126: Comprehensive test coverage for number formatting.

This new test procedure thoroughly evaluates the formatting of numeric values with:

  • Different value magnitudes (0, 0.1, 1, 10, 100, 1000)
  • Various decimal precisions (1-4 decimal places)
  • Negative values
  • Thousand separators

The test cases verify that the formatting correctly adapts to different value ranges and maintains appropriate precision.

src/BenchmarkOneScript/core/Модули/ПредставленияПоказателейБенчмарков.os (4)

10-10: Enhanced representation with unit-aware formatting.

Now passing the unit of measurement to ПредставлениеЧисла() enables context-aware numeric formatting based on unit type.


42-50: Simplified numeric representation with dynamic precision.

The ПредставлениеЧисла() function now properly delegates precision determination to the specialized function ПодобратьРазрядностьДробнойЧасти() and uses the resulting precision to format the number.


52-74: Well-designed algorithm for decimal precision determination.

This new function intelligently calculates decimal precision by:

  1. Handling special case of zero value
  2. Considering unit type (special handling for time units)
  3. Setting minimum and maximum precision limits
  4. Using logarithmic calculation based on value magnitude
  5. Rounding the value with calculated precision
  6. Adjusting precision based on actual decimal digits after rounding

This approach ensures appropriate precision for different value ranges and units.


115-126: Useful utility function for calculating decimal digits.

This helper function correctly determines the number of significant decimal digits in a fractional number, which supports precise formatting by eliminating trailing zeros.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonar-openbsl-ru-qa-bot
Copy link

Failed Quality Gate failed

  • 2 New Issues (is greater than 0)

Project ID: benchmark

View in SonarQube

@Stivo182 Stivo182 merged commit b46b551 into main May 6, 2025
19 of 20 checks passed
@Stivo182 Stivo182 deleted the feat/precision-in-column branch May 6, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant